﻿@model BrnMall.Web.MallAdmin.Models.StoreShipFeeModel

@section header{
    <title>编辑配送费用</title>
    <link type="text/css" rel="stylesheet" href="/admin_mall/content/css/site.css"/>
    <script type="text/javascript" src="/admin_mall/scripts/jquery.js"></script>
    <script type="text/javascript" src="/admin_mall/scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/admin_mall/scripts/jquery.validate.unobtrusive.js"></script>
    @if (Model.RegionId != -1)
    {
    <script type="text/javascript">
        var provinceId = @ViewData["provinceId"]; //省id
        var cityId = @ViewData["cityId"]; //市id

        //绑定省列表
        function bindProvinceList(provinceSelectObj, selectProvinceId) {
            $.get("/malladmin/tool/ProvinceList", function (data) {
                var provinceList = eval("(" + data + ")");
                if (provinceList.length > 0) {
                    var optionStr = "<option value='0'>全部</option>";
                    for (var i = 0; i < provinceList.length; i++) {
                        optionStr = optionStr + "<option value='" + provinceList[i].id + "'>" + provinceList[i].name + "</option>";
                    }
                    provinceSelectObj.html(optionStr);
                    if (selectProvinceId == undefined)
                        selectProvinceId = -1;
                    provinceSelectObj.find("option[value=" + selectProvinceId + "]").attr("selected", true);
                }
                else {
                    alert("加载省列表时出错！")
                }
            })
        }

        //绑定市列表
        function bindCityList(provinceId, citySelectObj, selectCityId) {
            $.get("/malladmin/tool/CityList?provinceId=" + provinceId, function (data) {
                var cityList = eval("(" + data + ")");
                if (cityList.length > 0) {
                    var optionStr = "<option value='0'>全部</option>";
                    for (var i = 0; i < cityList.length; i++) {
                        optionStr = optionStr + "<option value='" + cityList[i].id + "'>" + cityList[i].name + "</option>";
                    }
                    citySelectObj.html(optionStr);
                    if (selectCityId == undefined)
                        selectCityId = -1;
                    citySelectObj.find("option[value=" + selectCityId + "]").attr("selected", true);
                }
                else {
                    alert("加载市列表时出错！")
                }
            })
        }

        $(function () {
            //绑定省列表的改变事件
            $("#provinceSelect").change(function () {
                var selectedProvinceSelect = $(this);
                var selectedProvinceId = selectedProvinceSelect.find('option:selected').val();
                if (selectedProvinceId > 0) {
                    selectedProvinceSelect.parent().find(".countySelect").html("<option value='0'>全部</option>")
                    bindCityList(selectedProvinceId, selectedProvinceSelect.parent().find(".citySelect"));
                }
                else {
                    selectedProvinceSelect.parent().find(".countySelect").html("<option value='0'>全部</option>")
                }
                $("#regionId").val(selectedProvinceId);
            })

            //绑定市列表的改变事件
            $("#citySelect").change(function () {
                var selectedCitySelect = $(this);
                var selectedCityId = selectedCitySelect.find('option:selected').val();
                if (selectedCityId > 0) {
                    $("#regionId").val(selectedCityId);
                }
            })

            //绑定省列表
            bindProvinceList($("#provinceSelect"), provinceId);

            if (cityId > 0) {
                bindCityList(provinceId, $("#provinceSelect").parent().find(".citySelect"), cityId);
            }
        })
    </script>
        }
}

@section body{
<h1 class="rightH1">
店铺管理 &gt;&gt; 编辑配送费用
<div class="right">
<a href="@Html.Raw(ViewData["referer"].ToString())" class="menuBT"><img src="/admin_mall/content/images/goback.jpg"/>返回列表</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</h1>

@using (Html.BeginForm())
{
<input type="hidden" name="regionId" id="regionId" value="@Model.RegionId"/>
<div class="addTable">
<table width="100%">
@if (Model.RegionId != -1)
{
      <tr>
    <td width="80px" align="right">配送区域：</td>
    <td>
           <select class="provinceSelect" id="provinceSelect">
                <option selected="selected" value="0">全部</option>
           </select>
           <select class="citySelect" id="citySelect">
                <option selected="selected" value="0">全部</option>
           </select>
           
    </td>
    </tr>
}
      <tr>
    <td width="80px" align="right">起步值：</td>
    <td>@Html.TextBoxFor(x => x.StartValue, new { @class = "input", size = "3" })@Html.ValidationMessageFor(x => x.StartValue)</td>
    </tr>
          <tr>
    <td align="right">起步价：</td>
    <td>@Html.TextBoxFor(x => x.StartFee, new { @class = "input", size = "3" })@Html.ValidationMessageFor(x => x.StartFee)</td>
    </tr>
          <tr>
    <td align="right">加值：</td>
    <td>@Html.TextBoxFor(x => x.AddValue, new { @class = "input", size = "3" })@Html.ValidationMessageFor(x => x.AddValue)</td>
    </tr>
          <tr>
    <td align="right">加价：</td>
    <td>@Html.TextBoxFor(x => x.AddFee, new { @class = "input", size = "3" })@Html.ValidationMessageFor(x => x.AddFee)</td>
    </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td>
    <a href="" class="addBt" id="sumbitBut" ><img src="/admin_mall/content/images/submit.jpg" /></a>
            <script type="text/javascript">
                $(function () {
                    $("#sumbitBut").click(function () {
                        $("form:first").submit();
                        return false;
                    })
                });
        </script>
    </td>
    </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
</table>
</div>
    }
}